<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("comctrls.inc.php");
use_unit("components4phpfull/jtxmldatasource.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("components4phpfull/jtdivwindow.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class Emp_Fuel_Edit extends Page
{
       public $JSGetPrice = null;
       public $Label14 = null;
       public $JSMakeModel = null;
       public $cmbmanufacturer = null;
       public $cmbmodel = null;
       public $edOdNow = null;
       public $lblOdometerNow = null;
       public $GroupBox1 = null;
       public $Label13 = null;
       public $Label11 = null;
       public $edPlate = null;
       public $Label10 = null;
       public $Label9 = null;
       public $edYear = null;
       public $lblNo = null;
       public $edNo = null;
       public $Label2 = null;
       public $cmbmode = null;
       public $edMiles = null;
       public $lblMiles = null;
       public $lblLastOdometer = null;
       public $edOdLast = null;
       public $lblDate = null;
       public $dpdate = null;
       public $lblli = null;
       public $lblpr = null;
       public $btnShowType = null;
       public $btnShowFuel = null;
       public $lblType = null;
       public $cmbType = null;
       public $lblBrand = null;
       public $cmbBrand = null;
       public $edprice = null;
       public $Label7 = null;
       public $edTotcost = null;
       public $Label1 = null;
       public $edLiters = null;
       public $C = null;
       public $JSValidate = null;
       public $hfError = null;
       public $Label12 = null;
       public $JTDivType = null;
       public $JTGroupBox6 = null;
       public $btnAddType = null;
       public $btnDelType = null;
       public $edType = null;
       public $listType = null;
       public $JTDivFuel = null;
       public $JTGroupBox5 = null;
       public $btnAddFuel = null;
       public $btnDelFuel = null;
       public $edFuel = null;
       public $listFuel = null;
       public $JTDivOctane = null;
       public $JTGroupBox4 = null;
       public $btnAddOctane = null;
       public $btnDelOctane = null;
       public $edOctane = null;
       public $listOctane = null;
       public $JTDivCity = null;
       public $JTGroupBox3 = null;
       public $btnAddCity = null;
       public $btnDelCity = null;
       public $edCity = null;
       public $listCity = null;
       public $JTDivBrand = null;
       public $JTGroupBox1 = null;
       public $btnAddBrand = null;
       public $btnDelBrand = null;
       public $edBrand = null;
       public $listBrand = null;
       public $JTDivAccount = null;
       public $JTGroupBox2 = null;
       public $btnAddAccount = null;
       public $btnDelAccount = null;
       public $edAccount = null;
       public $listAccount = null;
       public $JTJavaScript18 = null;
       public $JTJavaScript17 = null;
       public $JTJavaScript16 = null;
       public $JTJavaScript15 = null;
       public $JTJavaScript14 = null;
       public $JTJavaScript13 = null;
       public $btnShowAccount = null;
       public $edEngine = null;
       public $Label8 = null;
       public $cmbAccount = null;
       public $Label4 = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $hfRfuelId = null;
       public $btnShowOctane = null;
       public $btnShowCity = null;
       public $JTJavaScript12 = null;
       public $JTJavaScript11 = null;
       public $JTJavaScript10 = null;
       public $JTJavaScript9 = null;
       public $JTJavaScript8 = null;
       public $JTJavaScript7 = null;
       public $JTJavaScript6 = null;
       public $JTJavaScript5 = null;
       public $JTJavaScript4 = null;
       public $JTSiteTheme1 = null;
       public $JTJavaScript3 = null;
       public $JTJavaScript2 = null;
       public $JTJavaScript1 = null;
       public $compid = null;
       public $edDealer = null;
       public $imgBack = null;
       public $hiddenVeh = null;
       public $hiddenRoute = null;
       public $hiddenEmp = null;
       public $cmbCity = null;
       public $Label5 = null;
       public $Label6 = null;
       public $ComboBox2 = null;
       public $Label3 = null;
       public $cmboctane = null;
       public $Image1 = null;
       function cmbmanufacturerJSChange($sender, $params)
       {

       ?>
       makeModel();
       return false;
       <?php

       }

       function cmbmodeJSChange($sender, $params)
       {

       ?>
       var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

       <?php

       }

       function Emp_Fuel_EditJSLoad($sender, $params)
       {

       ?>
       var mode = document.getElementById('cmbmode').value;
       //alert(mode);
       if(mode=='Select' || mode=='Cash')
       {
       document.getElementById('lblNo_outer').style.visibility='hidden';
       document.getElementById('edNo_outer').style.visibility='hidden';
       }
       if(mode=='FleetCard' || mode=='Credit')
       {
       document.getElementById('lblNo_outer').style.visibility='visible';
       document.getElementById('edNo_outer').style.visibility='visible';
       }

       document.getElementById(edPlate_outer).style.textTranform='uppercase';

       <?php

       }

       function edOdNowJSKeyUp($sender, $params)
       {

       ?>
       document.Emp_Fuel_Edit.edMiles.value = (document.Emp_Fuel_Edit.edOdNow.value) - (document.Emp_Fuel_Edit.edOdLast.value);
       <?php

       }

       function edOdLastJSKeyUp($sender, $params)
       {

       ?>
       document.Emp_Fuel_Edit.edMiles.value = (document.Emp_Fuel_Edit.edOdNow.value) - (document.Emp_Fuel_Edit.edOdLast.value);
       <?php

       }
       function edLitersJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edLiters','lblli');
       <?php

       }

       function edpriceJSBlur($sender, $params)
       {

       ?>
       //Add your javascript code here
       validateRequire('edprice','lblpr');
       <?php

       }

       function cmbTypeJSChange($sender, $params)
       {
       //echo $this->cmbType->ajaxCall('price');
       ?>
       getPrice();

       <?php

       }

       function cmbBrandJSChange($sender, $params)
       {
       //echo $this->cmbBrand->ajaxCall('price');
       ?>
       getPrice();

       <?php

       }

       function btnDelTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var TypeIndex = document.getElementById('listType').selectedIndex;
       var TypeValue = document.getElementById('listType')[TypeIndex].value;
       var comp = document.getElementById('compid').value;
       AjaxType3(TypeValue,comp);
       <?php

       }

       function btnAddTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addtype = document.getElementById('edType').value;

       var compider = document.getElementById('compid').value;
       AjaxType2(addtype,compider);
       document.getElementById('edType').value = "";
       <?php

       }

       function btnDelFuelJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
        var FuelIndex = document.getElementById('listFuel').selectedIndex;
        var FuelValue = document.getElementById('listFuel')[FuelIndex].value;
        var comp = document.getElementById('compid').value;
        AjaxFuel3(FuelValue,comp);
       <?php

       }

       function btnAddFuelJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addfuel = document.getElementById('edFuel').value;
       var compider = document.getElementById('compid').value;
       AjaxFuel2(addfuel,compider);
       document.getElementById('edFuel').value = "";
       <?php

       }

       function btnShowTypeJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivType').Show();
       document.getElementById('edType').value = "";
       <?php

       }

       function btnShowFuelJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivFuel').Show();
       document.getElementById('edFuel').value = "";
       <?php

       }

       function btnDelOctaneJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var OctaneIndex = document.getElementById('listOctane').selectedIndex;
       var OctaneValue = document.getElementById('listOctane')[OctaneIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxOctane3(OctaneValue,compider3);
       <?php

       }

       function btnAddOctaneJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addoctane = document.getElementById('edOctane').value;
       var compider = document.getElementById('compid').value;
       AjaxOctane2(addoctane,compider);
       document.Route_Fuel.edOctane.value = " ";
       <?php

       }


       function btnShowOctaneJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivOctane').Show();
       <?php

       }

       function btnDelCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var CityIndex = document.getElementById('listCity').selectedIndex;
       var CityValue = document.getElementById('listCity')[CityIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxCity3(CityValue,compider3);
       <?php

       }

       function btnAddCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addcity = document.getElementById('edCity').value;
       var compider = document.getElementById('compid').value;
       AjaxCity2(addcity,compider);
       document.Route_Fuel.edCity.value = " ";
       <?php

       }

       function btnShowCityJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivCity').Show();
       <?php

       }

       function btnAddBrandJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addbrand = document.getElementById('edBrand').value;
       var compider = document.getElementById('compid').value;
       AjaxBrand2(addbrand,compider);
       document.getElementById('edBrand').value = " ";
       <?php

       }

       function btnDelBrandJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var BrandIndex = document.getElementById('listBrand').selectedIndex;
       var BrandValue = document.getElementById('listBrand')[BrandIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxBrand3(BrandValue,compider3);
       <?php

       }


       function btnShowBrandJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('JTDivBrand').Show();
       document.getElementById('edBrand').value = "";
       <?php

       }



       function btnDelAccountJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var AccountIndex = document.getElementById('listAccount').selectedIndex;
       var AccountValue = document.getElementById('listAccount')[AccountIndex].value;
       var compider3 = document.getElementById('compid').value;
       AjaxAccount3(AccountValue,compider3);
       <?php

       }

       function btnAddAccountJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       var addaccount = document.getElementById('edAccount').value;
       var compider = document.getElementById('compid').value;
       AjaxAccount2(addaccount,compider);
      document.getElementById('edAccount').value = " ";
       <?php

       }


       function btnShowAccountJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('edAccount').value = " ";
       document.getElementById('JTDivAccount').Show();
       <?php

       }

       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/btn_back2.png"
       <?php

       }

       function edpriceJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Emp_Fuel_Edit.edTotcost.value = (document.Emp_Fuel_Edit.edLiters.value) * (document.Emp_Fuel_Edit.edprice.value);
       <?php

       }

       function edLitersJSKeyUp($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.Route_Fuel_Edit2.edTotcost.value = (document.Route_Fuel_Edit2.edLiters.value) * (document.Route_Fuel_Edit2.edprice.value);
       <?php

       }

       function btnCancelClick($sender, $params)
       {
       redirect('route_emp_fuel_list.php?emp='.$this->hiddenEmp->getValue());


       }


       function price()
       {
        $type_id = $this->cmbType->getItemIndex();
        $brand = $this->cmbBrand->getItemIndex();

        $query_type = "SELECT value FROM lookup_fuel_tbl WHERE id='".$type_id."'";
        $result_type = mysql_query($query_type) or die("SELECT FUEL TYPE ".mysql_error());
        $row_type = mysql_fetch_array($result_type);
        $type = $row_type['value'];

        $query_price = "SELECT price FROM fuel_price_tbl WHERE company_id='".$_SESSION['company_id']."' AND brand='".$brand."' AND type='".$type."'";
        $result_price = mysql_query($query_price) or die("SELECT PRICE ".mysql_error());
        $row_price = mysql_fetch_array($result_price);

        $price = $row_price['price'];
        $this->edprice->Text = $price;

        $total = $this->edprice->Text * $this->edLiters->Text;
        $this->edTotcost->setText($total);
       }

        function validateRequired($value, $lbl)
       {
          if($value == '' || $value == null)
          {
             $this->$lbl->Caption = '&darr; This field is required &darr;';
             $this->hfError->setValue('1');
          }
       }

       function Emp_Fuel_EditCreate($sender, $params)
       {
       $this->hfError->setValue('0');
       $this->lblpr->Caption = '';
       $this->lblli->Caption = '';

       $this->compid->Value = $_SESSION['company_id'];

       if($_SESSION['access_route']==1)
       {
       $this->btnSubmit->setVisible(false);
       $this->btnCancel->setVisible(false);
       }

       if($_SESSION['access_route']==2)
       {
       $this->btnSubmit->setVisible(true);
       $this->btnCancel->setVisible(true);
       }


       $emp = $_GET['emp'];
       $route = $_GET['route'];
       $veh = $_GET['veh'];
       $rfuel_id = $_GET['autoid'];
       $this->hiddenEmp->setValue($emp);
       $this->hiddenRoute->setValue($route);
       $this->hiddenVeh->setValue($veh);
       $this->hfRfuelId->setValue($rfuel_id);

       $this->imgBack->setLink('route_emp_fuel_list.php?emp='.$this->hiddenEmp->getValue());

       $result_fuel = mysql_query("select * from emp_fuel_tbl where autoid='".$this->hfRfuelId->getValue()."'");
       $row_fuel = mysql_fetch_array($result_fuel);
       $tracking = $row_fuel['track'];


       $result_veh = mysql_query("select * from vehicle_tbl where vehicle_id='".$this->hiddenEmp->getValue()."'")or die(mysql_error);
       $row_veh = mysql_fetch_array($result_veh);

       /*if($tracking=='hours')
       {
       $this->lblprev->Caption = 'Previous Hours:';
       $this->lblcurr->Caption = 'Current Hours:';
       }

       if($tracking=='distance')
       {
       $this->lblprev->Caption = 'Previous Odometer:';
       $this->lblcurr->Caption = 'Current Odometer:';
       }*/


       $this->cmbmode->ItemIndex = $row_fuel['payment_mode'];
       $this->edNo->Text = $row_fuel['card_num'];
       $this->dpdate->Text=$row_fuel['date'];
       $this->edOdLast->Text=$row_fuel['last_odometer'];
       $this->edOdNow->Text=$row_fuel['present_odometer'];
       $this->edMiles->Text=$row_fuel['miles'];
       $this->edLiters->Text=$row_fuel['gallons'];
       $this->edTotcost->Text=$row_fuel['tot_cost'];
       $this->edprice->Text=$row_fuel['price'];
       //$this->edEngine->Text=$row_fuel['engine'];
       $this->edDealer->Text=$row_fuel['dealer'];

       $this->edPlate->Text = $row_fuel['plate'];
       $this->edYear->Text = $row_fuel['year'];


       $selected_mnfr = $row_fuel['make'];
       $result_sel_mnfr = mysql_query("SELECT * FROM lookup_vehicle_tbl WHERE value='".$selected_mnfr."' AND company_id='".$_SESSION['company_id']."'") or die("GET ID".mysql_error());
       $row_sel_mnfr = mysql_fetch_array($result_sel_mnfr);

       $this->cmbmanufacturer->Clear();

       $result_mnfr = mysql_query("select * from lookup_vehicle_tbl where company_id='".$_SESSION['company_id']."' and category='manufacturer' order by value asc");
       $this->cmbmanufacturer->AddItem($selected_mnfr, null, $row_sel_mnfr['id']);
       while($row_mnfr = mysql_fetch_array($result_mnfr))
        {
            if($selected_mnfr!=$row_mnfr['value'])
            $this->cmbmanufacturer->AddItem($row_mnfr['value'], null, $row_mnfr['id']);
        }
       $this->cmbmanufacturer->setItemIndex($row_sel_mnfr['id']);

       $this->cmbmodel->Clear();
       $selected_model = $row_fuel['model'];
       $this->cmbmodel->AddItem($selected_model, null, $selected_model);
       $result_model = mysql_query("select * from lookup_models_tbl where mnfr_id='".$row_sel_mnfr['id']."'");
       while($row_model = mysql_fetch_array($result_model))
       {
           $model = $row_model['model_name'];
           if($selected_model!=$model)
           $this->cmbmodel->AddItem($model, null, $model);
       }


        $this->cmbOctane->Clear();
        $result_octane = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='octane/Types'");

        while($row_octane = mysql_fetch_array($result_octane))
        {
            $this->cmbOctane->AddItem($row_octane['value'], null, $row_octane['value']);
        }

        //list octane
        $this->edOctane->Text = "";
        $result_o = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='octane/Types'");

        while($row_o = mysql_fetch_array($result_o))
        {
            $this->listOctane->AddItem($row_o['value'], null, $row_o['value']);
        }

       $this->cmbAccount->Clear();
       $this->cmbAccount->AddItem('--Select--', null, null);
       $this->cmbAccount->ItemIndex=$row_fuel['account'];
        $result_account = mysql_query("select value from lookup_expense_tbl where company_id = '".$_SESSION['company_id']."' AND category='accounts'");
        while($row_account = mysql_fetch_array($result_account))
        {
            $this->cmbAccount->AddItem($row_account['value'], null, $row_account['value']);
        }


        //list account
        $this->edAccount->Text = "";
        $result_a = mysql_query("select value from lookup_expense_tbl where company_id = '".$_SESSION['company_id']."' AND category='accounts'");
        while($row_a = mysql_fetch_array($result_a))
        {
            $this->listAccount->AddItem($row_a['value'], null, $row_a['value']);
        }



       $this->cmbCity->Clear();
        $result_loc = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='state/province'");

        while($row_loc = mysql_fetch_array($result_loc))
        {
            $this->cmbCity->AddItem($row_loc['value'], null, $row_loc['value']);
        }

        //list city
         $this->edCity->Text = "";
         $result_c = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='state/province'");

        while($row_c = mysql_fetch_array($result_c))
        {
            $this->listCity->AddItem($row_c['value'], null, $row_c['value']);
        }


        /*$this->cmbDealer->Clear();
        $result_dealer = mysql_query("select value from lookup_fuel_tbl where category='dealer names'");

        while($row_dealer = mysql_fetch_array($result_dealer))
        {
            $this->cmbDealer->AddItem($row_dealer['value'], null, $row_dealer['value']);
        }*/

        //$this->cmbType->AddItem('', null, '');
        $this->cmbBrand->Clear();
        $this->cmbBrand->AddItem('--Select--', null, null);
        $this->cmbBrand->ItemIndex = $row_fuel['brand'];
        $result_brand = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='brands' order by value asc");

        while($row_brand = mysql_fetch_array($result_brand))
        {
            $this->cmbBrand->AddItem($row_brand['value'], null, $row_brand['value']);
        }

        $this->cmbType->Clear();
        $this->cmbType->AddItem('--Select--', null, null);
        $this->cmbType->ItemIndex = $row_fuel['type'];
        $result_fuel = mysql_query("select * from lookup_fuel_tbl where company_id='".$_SESSION['company_id']."' and category='octane/types' order by value asc");

        while($row_fuel = mysql_fetch_array($result_fuel))
        {
         $this->cmbType->AddItem($row_fuel['value'], null , $row_fuel['id']);
        }

      $this->listType->Clear();
      $result_type = mysql_query("select * from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='octane/Types' order by value asc");

      while($row_type = mysql_fetch_array($result_type))
      {
        $this->listType->AddItem($row_type['value'], null, $row_type['id']);
      }




       //list brand
        $result_b = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND category='brands' order by value asc");

        while($row_b = mysql_fetch_array($result_b))
        {
            $this->listFuel->AddItem($row_b['value'], null, $row_b['value']);
        }

       }

       function btnSubmitClick($sender, $params)
       {
       $this->validateRequired($this->edprice->Text, 'lblpr');
       $this->validateRequired($this->edLiters->Text, 'lblli');
       $error = $this->hfError->getValue();
       if($error == '1' || $number != $key)
       {
          $this->hfError->setValue('0');
          return false;
       }
       else if($error == '0')
       {

       $result_route = mysql_query("SELECT * FROM route_tbl WHERE route_id='".$this->hiddenRoute->getValue()."'")
       or die("GET ROUTE ".mysql_error());
       $row_route = mysql_fetch_array($result_route);
       $dr_id = $row_route['dr1_id'];

       $result_driver = mysql_query("SELECT * FROM employee_tbl WHERE autoid='".$dr_id."'")
       or die("GET DRIVER ".mysql_error());
       $row_driver = mysql_fetch_array($result_driver);


      /*$result_fuel = mysql_query("select * from rou_fuel_tbl where route_id='" . $this->hiddenRoute->getValue(). "'");
      $fuel_count = mysql_num_rows($result_fuel);
      if($fuel_count == 0)
      {
       $result_fuel_id = mysql_query("SELECT MAX(rfuel_id) as max FROM rou_fuel_tbl");
       $row_fuel_id = mysql_fetch_array($result_fuel_id);
       $fuel_id = $row_fuel_id['max']+1;

       $result = mysql_query("INSERT into rou_fuel_tbl (rfuel_id,
       company_id,
       veh_id,
       route_id,
       emp_id,
       gallons,
       price,
       brand,
       tot_cost,
       engine,
       dealer,
       octane,
       account,
       province)

       VALUES ('".$fuel_id."',
       '".$_SESSION['company_id']."',
       '".$this->hiddenVeh->getValue()."',
       '".$this->hiddenRoute->getValue()."',
       '".$this->hiddenEmp->getValue()."',
       '".$this->edLiters->Text."',
       '".$this->edprice->Text."',
       '".$this->cmbBrand->getItemIndex()."',
       '".$this->edTotcost->Text."',
       '".$this->edEngine->Text."',
       '".$this->edDealer->Text."',
       '".$this->cmbOctane->getItemIndex()."',
       '".$this->cmbAccount->getItemIndex()."',
       '".$this->cmbCity->getItemIndex()."')") or die ('INSERT FUEL -' . mysql_error());



       $result_vehfuel = mysql_query("INSERT into veh_fuel_tbl (route_fuel_id,
       company_id,
       vehicle_id,
       date,
       last_odometer,
       present_odometer,
       miles,
       gallons,
       price,
       tot_cost,
       engine,
       brand,
       dealer,
       account,
       province,
       driver)

       VALUES ('".$fuel_id."',
       '".$_SESSION['company_id']."',
       '".$this->hiddenVeh->getValue()."',
       '".$row_route['start_date']."',
       '".$row_route['odometer_start']."',
       '".$row_route['odometer_stop']."',
       '".$row_route['miles']."',
       '".$this->edLiters->Text."',
       '".$this->edprice->Text."',
       '".$this->edTotcost->Text."',
       '".$this->edEngine->Text."',
       '".$this->cmbBrand->getItemIndex()."',
       '".$this->edDealer->Text."',
       '".$this->cmbAccount->getItemIndex()."',
       '".$this->cmbCity->getItemIndex()."',
       '".$row_driver['lname'].','.$row_driver['fname']."')") or die ('INSERT VEH_FUEL -' . mysql_error());
      }
      else
      {
       */

       //last_odometer = '".$this->edOdLast->Text."',
       //miles = '".$this->edMiles->Text."',

       $mnfr_id = $this->cmbmanufacturer->getItemIndex();
       $result_mnfr = mysql_query("SELECT value FROM lookup_vehicle_tbl WHERE company_id='".$_SESSION['company_id']."' and id='".$mnfr_id."'");
       $row_mnfr = mysql_fetch_array($result_mnfr);

       mysql_query("update emp_fuel_tbl set
       date = '".$this->dpdate->getText()."',
       payment_mode = '".$this->cmbmode->getItemIndex()."',
       card_num = '".$this->edNo->Text."',

       plate = '".$this->edPlate->Text."',
       year = '".$this->edYear->Text."',
       make = '".$row_mnfr['value']."',
       model = '".$this->cmbmodel->getItemIndex()."',

       present_odometer = '".$this->edOdNow->Text."',
       gallons = '".$this->edLiters->Text."',
       price = '".$this->edprice->Text."',
       brand = '".$this->cmbBrand->getItemIndex()."',
       account = '".$this->cmbAccount->getItemIndex()."',
       type = '".$this->cmbType->getItemIndex()."',
       tot_cost = '".$this->edTotcost->Text."',
       engine = '".$this->edEngine->Text."',
       dealer = '".$this->edDealer->Text."'
       where autoid='".$this->hfRfuelId->getValue()."'")or die(mysql_error());


       $result_routefuel = mysql_query("select * from rou_fuel_tbl where route_id='" . $this->hfRfuelId->getValue(). "'");
       $row_routefuel = mysql_fetch_array($result_routefuel);
       $route_id = $row_routefuel['rfuel_id'];

       $fuel_t = $this->cmbType->getItemIndex();
       $result_ftype = mysql_query("select value from lookup_fuel_tbl where company_id = '".$_SESSION['company_id']."' AND id='".$fuel_t."'");
       $row_ftype = mysql_fetch_array($result_ftype);
       $ftype2 = $row_ftype['value'];

       /*mysql_query("update veh_fuel_tbl set

       date = '".$row_route['start_date']."',
       last_odometer = '".$row_route['odometer_start']."',
       present_odometer = '".$row_route['odometer_stop']."',
       miles = '".$row_route['miles']."',
       gallons = '".$this->edLiters->Text."',
       price = '".$this->edprice->Text."',
       tot_cost = '".$this->edTotcost->Text."',
       engine = '".$this->edEngine->Text."',
       brand = '".$this->cmbBrand->getItemIndex()."',
       dealer = '".$this->edDealer->Text."',
       account = '".$this->cmbAccount->getItemIndex()."',
       province = '".$this->cmbCity->getItemIndex()."',
       driver = '".$row_driver['lname'].','.$row_driver['fname']."'
       where route_fuel_id = '".$route_id."'")or die(mysql_error());*/

       /*mysql_query("update veh_fuel_tbl set
       date = '".$this->dpdate->getText()."',
       payment_mode = '".$this->cmbmode->getItemIndex()."',
       card_num = '".$this->edNo->Text."',
       last_odometer = '".$this->edOdLast->Text."',
       present_odometer = '".$this->edOdNow->Text."',
       miles = '".$this->edMiles->Text."',
       gallons = '".$this->edLiters->Text."',
       price = '".$this->edprice->Text."',
       tot_cost = '".$this->edTotcost->Text."',
       engine = '".$this->edEngine->Text."',
       brand = '".$this->cmbBrand->getItemIndex()."',
       dealer = '".$this->edDealer->Text."',
       account = '".$this->cmbAccount->getItemIndex()."',
       province = '".$this->cmbCity->getItemIndex()."',
       driver = '".$row_driver['lname'].','.$row_driver['fname']."',
       driver_id = '".$dr_id."',
       type = '".$ftype2."',
       ftype_id = '".$this->cmbType->getItemIndex()."'
       where route_fuel_id = '".$this->hfRfuelId->getValue()."'")or die(mysql_error());*/

      //UPDATE CURRENT ODOMETER/HOURS
      /*$result_fuel = mysql_query("select * from rou_fuel_tbl where rfuel_id='".$this->hfRfuelId->getValue()."' and route_id='".$this->hiddenRoute->getValue()."'");
      $row_fuel = mysql_fetch_array($result_fuel);
      $tracking = $row_fuel['track_by'];

      if($tracking=='distance')
      {
      $save_here = 'curr_tracking_value';
      }

      if($tracking=='hours')
      {
      $save_here = 'curr_hours';
      }

      mysql_query("UPDATE vehicle_tbl set ".$save_here." = '".$this->edOdNow->Text."' WHERE vehicle_id = '".$this->hiddenEmp->getValue()."'")or die(mysql_error());*/


      redirect('route_emp_fuel_list.php?emp='.$this->hiddenEmp->getValue());
      }
      }


}

global $application;

global $Emp_Fuel_Edit;

//Creates the form
$Emp_Fuel_Edit=new Emp_Fuel_Edit($application);

//Read from resource file
$Emp_Fuel_Edit->loadResource(__FILE__);

//Shows the form
$Emp_Fuel_Edit->show();

?>